<!--
 * @fileDesc: 时间节点
 * @Date: 2021-11-11 11:48:44
 * @LastEditors: white
 * @LastEditTime: 2021-11-11 16:20:36
 * @FilePath: /流程图/vue-draggable-workflow/src/components/timeNodeForm.vue
-->

<template>
    <div>
        <el-form ref="dataForm" :model="tempItem" label-width="80px">
            <el-form-item label="时间" prop="stepName">
                <template v-for="(ruleItem,index) in tempItem.ruleGroupList">
                    <el-date-picker
                        :key="index"
                        v-model="ruleItem.value"
                        style="width:100%"
                        type="datetime"
                        placeholder="选择日期"
                    />
                </template>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    import {clone} from "@/utils";

    function _getTempItem() {
        return {
            stepName: '时间',
            ruleGroupList: [{
                value: new Date()
            }]
        }
    }
    
    export default {
        name: "nodeNodeForm",
        props: {
            editItem: {
                type: Object,
            }
        },
        data() {
            return {
                tempItem: _getTempItem(),
                addForm:{
                    createDate: new Date()
                }
            }
        },
        created() {
            if (this.editItem && this.editItem.stepName) {
                this.tempItem = clone(this.editItem);
            }
        },

        methods: {
            // 传递表单数据给父组件的函数
            validateFormData() {
                return new Promise((resolve, reject) => {
                    this.$refs['dataForm'].validate((valid) => {
                        if (!valid) {
                            reject();
                            return;
                        }
                        resolve();
                    })
                });
            },

            formData() {
                // 节点类型和UID
                let tempItem = clone(this.tempItem)
                return tempItem
            }
        }
    }
</script>